import Vue from 'vue'
import Router from 'vue-router'
import Login from './router/login/login'
import Home from './router/home/home'

const defaultRouter = [{
  path: '/',
  redirect: 'login'
}]

Vue.use(Router)

let router = new Router({
  mode: 'history',
  // base: process.env.BASE_URL,
  routes: [...defaultRouter, ...Login, ...Home]
})

router.beforeEach((to, from, next) => {
  if (to.meta.title || to.params.message) {
    document.title = to.meta.title || to.params.message.title
  } else {
    document.title = '后台管理系统'
  }
  next()
})

export default router
